const User = require('./User');
const Question = require('./Question');
const Resume = require('./Resume');

// 建立模型之间的关联
const associate = () => {
  // User 和 Resume 的关联
  User.hasMany(Resume, {
    foreignKey: 'userId',
    as: 'resumes'
  });
  Resume.belongsTo(User, {
    foreignKey: 'userId',
    as: 'user'
  });

  // User 和 Question 的关联（用于考试历史）
  User.hasMany(Question, {
    through: 'UserExamHistory',
    as: 'examQuestions'
  });
  Question.belongsToMany(User, {
    through: 'UserExamHistory',
    as: 'users'
  });
};

module.exports = {
  User,
  Question,
  Resume,
  associate
}; 